package com.jweb.framework.service.sqlmap.support;

import java.sql.Connection;
import java.util.Properties;

import javax.sql.DataSource;

import org.apache.ibatis.session.TransactionIsolationLevel;
import org.apache.ibatis.transaction.Transaction;
import org.apache.ibatis.transaction.TransactionFactory;
import org.springframework.util.Assert;

/**
 * 修改人： Thomas
 * 修改内容：新增 
 * 类说明：定制MyBatis如何处理事务
 */
public class SpringManagedTransactionFactory implements TransactionFactory {
	
	protected final DataSource dataSource ;
	
	public SpringManagedTransactionFactory(DataSource dataSource){
		Assert.notNull(dataSource , "No DataSource specified");
		
		this.dataSource = dataSource ;
	}
	
	/*public Transaction newTransaction(Connection connection , boolean flag){
		return (Transaction) new SpringManagedTransaction(connection , this.dataSource);
	}*/
	
	public void setProperties(Properties properties){
		
	}

	public Transaction newTransaction(Connection connection) {
		/*// TODO Auto-generated method stub
		return null;*/
		return (Transaction) new SpringManagedTransaction(connection , this.dataSource);
	}

	public Transaction newTransaction(DataSource datasource,
			TransactionIsolationLevel transactionisolationlevel, boolean flag) {
		// TODO Auto-generated method stub
		return null;
	}
	
	
}
